$(document).ready(function(){

///////////////
/*注册页的逻辑*/
//////////////

$('#loginBtn').click(function(e){
	e.preventDefault();
	
	var username 	= $('#loginName').val();
	var password 	= $('#loginPwd').val();
	
	//1判断是否都填写完整了
	if(!loginName){
		alert('请填写用户名');
		$('#loginName').focus();
	}else if(!loginPwd){
		alert('请填写登录密码');
		$('#loginPwd').focus();
	}else{
		$.ajax({
			type:'post',
			url:'../actions/userAction.php',
			data:{
				act				:'login',
				username		:username,
				password		:password
			}, 
			async: true,	
			beforeSend: function(){
				showMistAndWait();
			},
			success:function(data){	
				console.log(data);
				if(data == 'success'){
					window.location.href = 'index.php'
					hideMistAndWait();
				}else if(data == 'fail'){
					alert('账号密码错误');
					hideMistAndWait();
				}
			}
		});
	}
});
	
});

function showMistAndWait(){				
	$('.waiting').removeClass('hide');
	$('.mist').removeClass('hide');
}

function hideMistAndWait(){				
	$('.waiting').addClass('hide');
	$('.mist').addClass('hide');
}


